package com.tlibrary.service;

import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @Author：wcc
 * @Description：
 * @Date：Create in: 2019/3/30--15:04
 */
public class aa {


    public static void main(String[] args) {
        File file = new File("D:/test.doc");
        try {
            FileInputStream fis = new FileInputStream(file);
            HWPFDocument hwpfd = new HWPFDocument(fis);
            WordExtractor wordExtractor = new WordExtractor(hwpfd);
            String[] paragraph = wordExtractor.getParagraphText();
            for (int i = 0; i < paragraph.length; i++) {
                System.out.println(paragraph[i]);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
